import java.util.Scanner;

/**
 * @author ShenTuZhiGang
 * @version 1.0.0
 * @email 1600337300@qq.com
 * @date 2021-09-26 20:22
 */
public class ExamTencent2021092602 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- != 0) {
            int n = scanner.nextInt();
            int[] a = new int[n];
            int[] dp = new int[n];
            long ans = Long.MIN_VALUE;
            for (int i = 0; i < n; i++) {
                a[i] = scanner.nextInt();
                dp[i] = dp[i] + a[i];
                if (i + a[i] >= n) {
                    ans = Math.max(ans, dp[i]);
                    continue;
                }
                dp[i + a[i]] = Math.max(dp[i + a[i]], dp[i]);
            }
            System.out.println(ans);
        }
    }
}